# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器，以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。

# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
#FROM harbor.csiitl.com/library/dotnet/aspnet:9.0-alpine-time AS base
FROM registry.cn-shenzhen.aliyuncs.com/zhuyuhui/aspnet:9.0 AS base

#RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories
## 安装必要的依赖
#RUN apk add --no-cache libgdiplus
#RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

#RUN apt-get update
#RUN apt-get update -y && apt-get install -y libgdiplus && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
#COPY src/Service.Auth/Service.Auth.Api/msyh.ttf /usr/share/fonts/msyh.ttf



USER $APP_UID
WORKDIR /app
EXPOSE 8080
# 此阶段用于生成服务项目
#FROM harbor.csiitl.com/library/dotnet/sdk:9.0-alpine-time AS build
FROM registry.cn-shenzhen.aliyuncs.com/zhuyuhui/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release	
WORKDIR /src
# 复制并使用 NuGet.config 文件 
COPY ["NuGet.Config", "./"]
COPY ["Service.Auth/Service.Auth.Api/Service.Auth.Api.csproj", "Service.Auth/Service.Auth.Api/"]
COPY ["Service.Auth/Service.Auth.Domain/Service.Auth.Domain.csproj", "Service.Auth/Service.Auth.Domain/"]
COPY ["Service.Auth/Service.Auth.Infrastructure/Service.Auth.Infrastructure.csproj", "Service.Auth/Service.Auth.Infrastructure/"]
COPY ["Service.Core/Service.Core.Identity/Service.Core.Identity.csproj", "Service.Core/Service.Core.Identity/"]
COPY ["Service.Framework/Service.Framework.csproj", "Service.Framework/"]
COPY ["Service.Core/Service.Core/Service.Core.csproj", "Service.Core/Service.Core/"]
COPY ["Service.Core/Service.Core.Repository/Service.Core.Repository.csproj", "Service.Core/Service.Core.Repository/"]
RUN dotnet restore "./Service.Auth/Service.Auth.Api/Service.Auth.Api.csproj" --configfile "NuGet.Config"
COPY . .
WORKDIR "/src/Service.Auth/Service.Auth.Api"
RUN dotnet build "./Service.Auth.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

# 此阶段用于发布要复制到最终阶段的服务项目
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Service.Auth.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# 此阶段在生产中使用，或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Service.Auth.Api.dll"]